package com.wksc.framework.impexp.pattern;

import com.wksc.framework.impexp.bean.BaseFormatParams;

import java.util.Date;

/**
 * <p> Title(文件名): ${file_name} </p>
 * <p> Description(描述): ${todo} </p>
 * <p> Copyright(版权): Copyright (c) ${year} </p>
 * <p> Company(公司): 成都四方信息技术有限公司 </p>
 * <p> CreateTime(生成日期)：11-11-15上午11:44 </p>
 *
 * @author wanglei
 * @version ${project_name}
 */
public class DatePattern implements FormatPattern{
	private static final long serialVersionUID = 7274915667249150628L;

	private DatePattern(){}
	
	private static DatePattern INSTANCE = new DatePattern();
	
	public static DatePattern getINSTANCE(){
		return INSTANCE;
	}
    @Override
    public synchronized String format(BaseFormatParams params) {
    	String result;
    	Date date;
    	try {
			if(params.getCellContent().getClass() != Class.forName("java.util.Date")) {
                date = new Date();
                //CalendarTools.parse(CalendarTools.FD_ALL, params.getCellContent().toString());
            }else{
				date = (Date)params.getCellContent();
			}

            result = "";
                    //CalendarTools.format(CalendarTools.FD_ALL, date);
		} catch (Exception e){
			result = params.getCellContent().toString();
		}
    	return result;
    }
}
